﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CommunitySystem
{
    public class People
    {
        public People()
        {
            Childs = new ObservableCollection<People>();
        }

        public string Title { get; set; }

        public int Count { get; set; }

        public ObservableCollection<People> Childs { get; set; }
    }
    public partial class OrgInfoBoardPage : UserControl
    {
        private readonly ObservableCollection<People> _data;
        public OrgInfoBoardPage()
        {
            InitializeComponent();
            _data = new ObservableCollection<People>
                        {
                            new People
                                {
                                    Title = "实有人口",
                                    Count = 99180,
                                    Childs = new ObservableCollection<People>
                                                 {
                                                     new People
                                                         {
                                                             Title = "户籍人口",
                                                             Count = 79169,
                                                             Childs = new ObservableCollection<People>
                                                                  {
                                                                       new People
                                                                          {
                                                                               Title = "人在户在",
                                                                               Count = 41739,
                                                                          },
                                                                          new People
                                                                          {
                                                                               Title = "人户分离",
                                                                               Count = 37430,
                                                                               Childs = new ObservableCollection<People>
                                                                                 {
                                                                                      new People
                                                                                          {
                                                                                              Title = "街道内人在户在",
                                                                                              Count = 5931,
                                                                                          },
                                                                                      new People
                                                                                         {
                                                                                              Title = "街道外人户分离",
                                                                                              Count = 31499,
                                                                                         }
                                                                                 } 
                                                                          }
                                                                  }          
                                                         }
                                                 }
                                }
                        };
            treeGrid.ItemsSource = _data;
            SetButtonState(btnPos);
        }
        private void SetButtonState(Button selectedBtn)
        {
            selectedBtn.Background = new SolidColorBrush(Color.FromArgb(0x44, 0xff, 0xff, 0xff));
            foreach (Button btn in btnGroup.Children)
            {
                if (btn != selectedBtn)
                {
                    btn.Background = new SolidColorBrush(Colors.Transparent);
                }
            }
        }
        private void btnPos_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }
        private void btnDegree_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }

        private void btnAge_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }

        private void btnWorkYear_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }

        private void btnSex_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }

        private void btnEmpFlow_Click(object sender, RoutedEventArgs e)
        {
            SetButtonState(sender as Button);
        }

        private void tbEmpRealCount_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            tbOrgName.Visibility = System.Windows.Visibility.Collapsed;
        }
    }
}
